package com.moss.system.service.impl;

import com.moss.common.entity.SysSampleOrgEntity;
import com.moss.system.mapper.SampleOrgMapper;
import com.moss.system.service.SampleOrgService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SampleOrgServiceImpl implements SampleOrgService {

    @Resource
    SampleOrgMapper sampleOrgMapper;

    @Override
    public List<SysSampleOrgEntity> listSampleOrg(SysSampleOrgEntity sampleOrg) {
        return sampleOrgMapper.selectList(sampleOrg);
    }

    @Override
    public boolean checkCodeAndNameEq(String sampleOrgCode, String sampleOrgName) {
        SysSampleOrgEntity sampleOrg = sampleOrgMapper.selectByCode(sampleOrgCode);
        return sampleOrg == null || !sampleOrgName.equals(sampleOrg.getSampleOrgName());
    }

    @Override
    public void saveSampleOrg(SysSampleOrgEntity sampleOrg) {
        sampleOrgMapper.insert(sampleOrg);
    }

    @Override
    public SysSampleOrgEntity getSampleOrg(Long id) {
        return sampleOrgMapper.selectById(id);
    }


    @Override
    public void updateSampleOrg(SysSampleOrgEntity sampleOrg) {
        sampleOrgMapper.updateById(sampleOrg);
    }

    @Override
    public void deleteSampleOrg(Long[] ids) {
        sampleOrgMapper.deleteById(ids);
    }
}
